﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MeetingAdd.aspx.cs" Inherits="Meeting.Web.Admin.MeetingSet.MeetingAdd" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>会议添加</title>
    <link href="../../Css/SmartWizard/smart_wizard.css" rel="stylesheet" type="text/css" />
    <link href="../../Css/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.smartWizard-2.0.js"></script>
    <script src="../../Scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/cupertino/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/icon.css" />
    <script type="text/javascript" src="../../Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../Scripts/locale/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="../../Css/zTreeStyle/zTreeStyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/cupertino/easyui.css" />
    <script type="text/javascript" src="../../Scripts/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.ztree.excheck-3.5.js"></script>
    <script src="../../Scripts/datagrid-detailview.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/common.js"></script>
    <script src="../../Scripts/Json2.js" type="text/javascript"></script>
    <!--ardialog-->
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/plugins/iframeTools.js"></script>
    <script type="text/javascript">
        //树初始化
        var zTree;
        var setting = { check: { enable: true },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "account",
                    pIdKey: "parent",
                    rootPId: "0"
                }
            },
            async: {
                enable: true

            },
            callback: {
                beforeAsync: zTreeBeforeAsync,      // 异步加载事件之前得到相应信息
                asyncSuccess: zTreeOnAsyncSuccess,
                onCheck: zTreeOnCheck

            }
        };
        function zTreeBeforeAsync() {
            $("#imgShow").show();
        }
        function zTreeOnAsyncSuccess() {
            $("#imgShow").hide();
        }
        $(function () {
            // if (request("psnID") == "") window.location = defaultUrl;
            // Smart Wizard     	
            $('#wizard').smartWizard({
                transitionEffect: 'slideleft',
                onLeaveStep: leaveAStepCallback,
                onFinish: onFinishCallback,
                enableFinishButton: true
            });
            function leaveAStepCallback(obj, context) {
                var step_num = obj.attr('rel');
                if (context.fromStep > context.toStep) {//判读从哪步到哪一步
                    if (context.fromStep == 3) flag = false; //判断从第三个反过来，第二步到第三部切换不处理
                    return true;
                } else {
                    return validateSteps(step_num,context);
                }
            }
            function onFinishCallback() {
                $.messager.confirm("提示", "点击完成将创建新会议，确定吗？", function (c) {
                    if (!c) return;
                    window.location = window.location;
                });
            }
            //************************************step1初始化****************************//
            //会议室
            $("#RoomId").combobox({
                url: 'MeetingOperation.ashx?method=GetRoom',
                valueField: 'Id',
                textField: 'Name'
            })
            //视频会议室 VideoRoomId
            $("#VideoRoomId").combobox({
                url: 'MeetingOperation.ashx?method=GetVideoRoom',
                valueField: 'Id',
                textField: 'Name'
            })
            //设置会议类型 
            $("#CategoryId").combobox({
                url: '../MeetingStand/StandMeetingOperation.ashx?method=GetMeetingCategory',
                valueField: 'Id',
                textField: 'Name'
            });

            //************************************step1结束****************************//
            $("#editSelect").hide();
        });



        function validateAllSteps() {
            var isStepValid = true;

            if (!isStepValid) {
                $('#wizard').smartWizard('showMessage', '请按提示操作修改错误项');
            }
            return isStepValid;
        }


        //验证步进
        var flag = true;
        function validateSteps(step, context) {             
           
            var isStepValid = true;
            if (step == 1) {
                if (MeetingInfoAdd() == false) {
                    isStepValid = false;
                    jQuery('#wizard').smartWizard('setError', { stepnum: step, iserror: true });
                }
                else {

                    $("#Step2MeetingName").html($("#Name").val());
                    //************************************step2初始化****************************//
                    InitStandMeeting();
                    //************************************step2结束****************************//
                    jQuery('#wizard').smartWizard('setError', { stepnum: step, iserror: false }); //验证通过
                }
            }
            //第二步
            if (step == 2) {
                if (SaveMeetingEmployee() == false) {
                    isStepValid = false;
                    jQuery('#wizard').smartWizard('setError', { stepnum: step, iserror: true });
                }
                else {
                    if (flag) {
                        $("#Step3MeetingName").html($("#Name").val());
                        InitTopic(); //
                        $('#wizard').smartWizard('setError', { stepnum: step, iserror: false });
                    } else { flag = true; }
                }

            }
            //第三步
            if (step == 3) {
                if (SaveMeetingTopic() == false) {
                    isStepValid = false;
                    jQuery('#wizard').smartWizard('setError', { stepnum: step, iserror: true });
                }
                else {
                    //InitStep4();
                    $('#wizard').smartWizard('setError', { stepnum: step, iserror: false });
                }
            }
            if (step == 4) {
                InitPlate();
            }
            if (step == 5) {
                InitVote();
            }
            if (step == 6) {
                isStepValid = false
                if (SaveMeetingVote() == false) {
                    isStepValid = false;
                    jQuery('#wizard').smartWizard('setError', { stepnum: step, iserror: true });
                }
                else {
                    $('#wizard').smartWizard('setError', { stepnum: step, iserror: false });
                    $.messager.confirm("询问", "确定要激活会议吗？", function (c) {
                        if (!c) return;
                        var postData = { Id: $("#Id").val() };
                        $.post("MeetingOperation.ashx?method=ActiveMeeting", postData, function (data) {
                            if (data.success == true) {
                                isStepValid = true;
                                $.messager.alert("提示", "会议激活成功");

                            }
                        });
                    });
                }
            }
            return isStepValid;
        }
        // Email Validation
        function isValidEmailAddress(emailAddress) {
            var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
            return pattern.test(emailAddress);
        }
        /*************************step1*******************************************/
        //公共变量
        var CategoryId = "";
        //第一步 保存会议信息        
        function MeetingInfoAdd() {
            var IsSuccess = false;
            //验证表单
            if (jQuery("#formStep1").form('validate') == false) {
                return false;
            }
            var Id = $("#Id").val();

            var rolestr = "";
            try {
                var strs = $("#CategoryId").combobox("getValue").split('#');
                CategoryId = strs[0]; //会议类型
                rolestr = strs[1];
            } catch (ex) {
                $.messager.alert("提示", "获取会议类型出错" + ex.Message);
                return false;
            }

            var Name = $("#Name").val();
            var HostId = ""; //$("#HostId").val();
            var HostName = ""; // $("#Host").val();
            var HostRoleId = ""; // $("#HostRoleId").val();
            //
            var StartDate = $("#StartDate").val();
            var EndDate = $("#EndDate").val();
            if (StartDate == "" || EndDate == "") {
                $.messager.alert("提示", "请选择会议时间");
                return false;
            }
            //            if (checkAskDate(StartDate, EndDate) == false) {
            //                return false;
            //            }
            var RoomId = $("#RoomId").combobox('getValue');
            var VideoRoomId = $("#VideoRoomId").combobox('getValue');
            var Duration = $("#Duration").val();
            var Status = $("#Status").combobox('getValue');
            //
            var postData = { Id: Id, CategoryId: CategoryId, Name: Name, HostId: HostId, HostName: HostName, HostRoleId: HostRoleId,
                StartDate: StartDate, EndDate: EndDate, RoomId: RoomId, Duration: Duration, VideoRoomId: VideoRoomId,
                Status: Status
            };
            //提交
            $.post("MeetingOperation.ashx?method=MeetingInfoAdd", postData, function (data) {
                if (data.success == true) {
                    $("#Id").val(data.Message); //成功后记录会议ID
                    IsSuccess = true;
                    $.messager.show({ title: "提示", msg: "保存成功！", showType: 'show', timeout: 500 });
                    return true;

                } else {
                    $.messager.alert("提示", data.Message);
                    return false;
                }
            });
        }
        /*************************step1*******************************************/
        //第二步 保存人员信息        
        /*************************step2*******************************************/

        //设置显示
        function InitStandMeeting() {
            var CategoryId = "";
            try {
                var strs = $("#CategoryId").combobox("getValue").split('#');
                CategoryId = strs[0];
            } catch (ex) {
                $.messager.alert("提示", "获取会议类型出错" + ex.Message);
                return;
            }
            //会议类型
            $("#StandMeeting").combobox({
                url: 'MeetingOperation.ashx?method=GetStandMeeting&CategoryId=' + CategoryId,
                valueField: 'Id',
                textField: 'Name',
                onSelect: function (itm) {  //获取常设会议配置人员 
                    $("#tbEmployee").datagrid({
                        url: "../MeetingStand/StandMeetingOperation.ashx?method=GetMeetingEmployeeById&Id=" + itm.Id,
                        idField: 'EmployeeId'
                    });
                }
            });
//            if ($("#Id").val() != "") { //加载已选择  这里可能用不到
//                $("#tbEmployee").datagrid({
//                    url: 'MeetingEditOperation.ashx?method=GetSelEmployee&Id=' + $("#Id").val(),
//                    singleSelect: true,
//                    idField: 'EmployeeId'
//                });
//            }
        }
        function GetOaUser() {

            var CategoryId = "";
            var rolestr = "";
            try {
                var strs = $("#CategoryId").combobox("getValue").split('#');
                CategoryId = strs[0]; //会议类型
                rolestr = strs[1];
            } catch (ex) {
                $.messager.alert("提示", "获取会议类型出错" + ex.Message);
                return;
            }
            $.ajax({
                type: "POST",
                url: "../SelectBase/SelectOperation.ashx?method=GetOAEmploy&role=" + rolestr,
                dataType: "json",
                success: function (data, textStatus) {
                    //alert(data);
                    zTree = $.fn.zTree.init($("#treeMain"), setting, data);
                    zTree.expandAll(true);
                    zTree.setting.check.chkboxType = { "Y": "ps", "N": "ps" };
                    zTree.setting.callback.onCheck = zTreeOnCheck;
                    // zTree.checkAllNodes(true);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {

                }
            });
        }
        function onClick(event, treeId, treeNode) {

        }

        //添加与会人员
        function AddEmployee() {
            var categoryValue = $("#CategoryId").combobox("getValue");
            var strs = categoryValue.split('#');
            if (strs.length < 2) {
                $.messager.alert("提示", "请选择会议类型");
                return;
            }
            CategoryId = strs[0]; //会议类型
            var rolestr = strs[1];
            if (rolestr == "" || rolestr == undefined) {
                $.messager.alert("提示", "没有设置会议角色，请先设置该会议类型的角色。");
                return;
            }

            var radStr = Math.random();
            var url = "../SelectBase/SelectOAUser.aspx" + '?Radstr=' + radStr + "&RoleId=" + rolestr;
            art.dialog.open(url, {
                id: 'AddEmployee', title: '选择参会人', width: 500, height: 430, lock: true,
                close: function () {
                    var selNodeJson = art.dialog.data('selNode'); // 读取人员选择返回值
                    //  alert(selNodeJson);
                    if (selNodeJson != "") {
                        try {
                            var data = JSON.parse(selNodeJson);
                            DelAll();
                            for (i = 0; i < data.length; i++) {
                                $('#tbEmployee').datagrid('appendRow', data[i]);
                            }
                        } catch (ex) { }
                    }
                }
            }, true);
        }
        function DelAll() {
            var rows = $('#tbEmployee').datagrid('getRows');
            for (i = rows.length - 1; i >= 0; i--) {
                $('#tbEmployee').datagrid('deleteRow', i);
            }
        }

        function AppendGrid(tn) {
            if (tn.nodetype != "user") return;
            $('#tbEmployee').datagrid('appendRow', { EmployeeId: tn.account, EmployeeName: tn.name, RoleId: tn.parent, EmployeeTitle: tn.title, Sort: 10000 });
            editIndex = $('#tbEmployee').datagrid('getRows').length - 1;
            if (editIndex == -1 || editIndex == undefined) editIndex = 0;
            $('#tbEmployee').datagrid('selectRow', editIndex)
						.datagrid('beginEdit', editIndex);
        }
        function DelGrid(tn) {
            if (tn.nodetype != "user") return;
            var index = $('#tbEmployee').datagrid('getRowIndex', tn.account);
            $('#tbEmployee').datagrid('deleteRow', index);
        }
        //树选中事件
        function zTreeOnCheck(event, treeId, treeNode) {
            $('#tbEmployee').datagrid('loading');
            nodes = zTree.getChangeCheckedNodes();
            for (var i = 0, l = nodes.length; i < l; i++) {
                nodes[i].checkedOld = nodes[i].checked;
                var treeNode = nodes[i];
                if (treeNode.checked == true) {
                    AppendGrid(treeNode);

                } else {
                    DelGrid(treeNode);
                }
            }
            $('#tbEmployee').datagrid('loaded');
        }
        function EditSort() {
            var rows = $('#tbEmployee').datagrid('getRows');
            for (i = 0; i < rows.length; i++) {
                $('#tbEmployee').datagrid('beginEdit', i);
            }
        }

        //选择人员选取方式
        function SetSelectEmpoyee(obj) {

//            var rows = $('#tbEmployee').datagrid('getRows');
//            for (i = rows.length - 1; i >= 0; i--) {
//                var row = rows[i];
//                var index = $('#tbEmployee').datagrid('getRowIndex', row);
//                $('#tbEmployee').datagrid('deleteRow', index);
//            }

            if ($(obj).attr("checked") == "checked") {
                if ($(obj).val() == "oa") {
                    $("#trStandMeeting").hide();
                    $("#trOAuser").show();
                    $("#editSelect").show();
                }
                else {
                    $("#trStandMeeting").show();
                    $("#trOAuser").hide();
                    $("#editSelect").hide();
                    //读取常设会议信息
                    InitStandMeeting();
                }
            }

        }

        //设置主持人
        function SetHost() {

            var row = $("#tbEmployee").datagrid("getSelected");
            if (row) {
                $("#Step2HostId").val(row.EmployeeId);
                $("#Step2Host").val(row.EmployeeName);
                $("#Step2RoleId").val(row.RoleId);
                $("#Step2HostTitle").val(row.EmployeeTitle);
            }
        }
        //***********************获取人员数选中的人
        //获取已选择人员
        function GetSelectEmployee() {
            var rows = $('#tbEmployee').datagrid('getRows');
            for (i = 0; i < rows.length; i++) {
                var ed = $('#tbEmployee').datagrid('getEditor', { index: i, field: 'Sort' });

                if (ed != null && $(ed.target).val() == "") $(ed.target).val("10");
                $('#tbEmployee').datagrid('endEdit', i);
            }
            var data = $("#tbEmployee").datagrid("getData");
            if (data) return data.rows;
            return "";
        }
        //***********************结束递归
        //保存参会人员
        function SaveMeetingEmployee() {
            //验证表单
            if ($("#formSetp2").form('validate') == false) {
                return false;
            }
            //获取选中人员
            var selEmployee = GetSelectEmployee();
            if (selEmployee == "") {
                $.messager.alert("提示", "请选择参会人员");
                return false;
            }
            selEmployee = JSON.stringify(selEmployee);


            var Id = $("#Id").val(); //会议ID            
            var HostId = $("#Step2HostId").val();
            var Host = $("#Step2Host").val();
            var HostRoleId = $("#Step2RoleId").val();
            var HostTitle = $("#Step2HostTitle").val();
            //
            if (Host == "") {
                $.messager.alert("提示", "请选择会议主持人");
                return false;
            }
            //
            var postData = { Id: Id, HostId: HostId, Host: Host, HostRoleId: HostRoleId, HostTitle: HostTitle, selEmployee: selEmployee };
            //提交 
            $.post("MeetingOperation.ashx?method=SaveMeetingEmployee", postData, function (data) {
                if (data.success == true) {
                    return true;
                } else {
                    $.messager.alert("提示", "保存失败：" + data.Message);
                    return false;
                }
            });
        }

        /*************************step2*******************************************/
        /*************************step3开始*******************************************/

        function InitTopic() {
            $('#topicSelect').datagrid({
                url: 'MeetingOperation.ashx?method=GetSelectTopic&Id=' + $("#Id").val(),
                singleSelect: true
            });
        }

        function SelectTopic() {
            var categoryValue = $("#CategoryId").combobox("getValue");
            var strs = categoryValue.split('#');
            if (strs.length < 2) {
                $.messager.alert("提示", "请选择会议类型");
                return;
            }
            CategoryId = strs[0]; //会议类型
            var rolestr = strs[1];
            if (rolestr == "" || rolestr == undefined) {
                $.messager.alert("提示", "请选择会议类型");
                return;
            }

            var radStr = Math.random();
            var url = "../SelectBase/SelectTopic.aspx" + '?Radstr=' + radStr + "&CategoryId=" + CategoryId;
            art.dialog.open(url, {
                id: 'AddTopic', title: '选择议题', width: 650, height: 520, lock: true,
                close: function () {
                    var selNodeJson = art.dialog.data('selJson'); // 读取人员选择返回值
                    //  alert(selNodeJson);
                    if (selNodeJson != "") {
                        try {
                            var data = JSON.parse(selNodeJson);

                            DelSelectTopic();
                            for (i = 0; i < data.length; i++) {
                                $('#topicSelect').datagrid('appendRow', data[i]);

                            }
                        } catch (ex) { }
                    }
                }
            }, true);
        }
        //        function formatPass(val, row) {
        //            if (row.IsPass == true)
        //                return "通过";
        //            else
        //                return "未通过";
        //        }

        function DelSelectTopic() {
            var rows = $('#topicSelect').datagrid('getRows');
            for (i = rows.length - 1; i >= 0; i--) {
                $('#topicSelect').datagrid('deleteRow', i);
            }
        }
        //从已选择中移除
        function DelSelect(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"RemoveSelect('" + row.TopicId + "');\"  >移除</a> ";
        }
        function RemoveSelect(TopicId) {
            var data = $('#topicSelect').datagrid('getData');
            var index = -1;
            for (i = 0; i < data.total; i++) {
                if (data.rows[i].TopicId == TopicId) {
                    index = i;
                    break;
                }
            }
            $('#topicSelect').datagrid('deleteRow', index);
        }
        function EditTopicSort() {
            var rows = $('#topicSelect').datagrid('getRows');
            for (i = 0; i < rows.length; i++) {
                $('#topicSelect').datagrid('beginEdit', i);
            }
        }
        //设置结束编辑
        function GetSelectTopic() {
            var rows = $('#topicSelect').datagrid('getRows');
            for (i = 0; i < rows.length; i++) {
                var ed = $('#topicSelect').datagrid('getEditor', { index: i, field: 'Sort' });

                if (ed != null && $(ed.target).val() == "") $(ed.target).val("10");
                $('#topicSelect').datagrid('endEdit', i);
            }
        }

        function formatTopicEmployee(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"TopicEmployee('" + row.TopicId + "');\"  >设置主讲人</a> ";
        }
        function TopicEmployee(id) {
            var radStr = Math.random();
            var url = "../SelectBase/SelectMeetingUser.aspx" + '?Radstr=' + radStr + "&MeetingId=" + $("#Id").val();
            art.dialog.open(url, {
                id: 'ChangeTopicEmploye', title: '设置主讲人', width: 500, height: 350, lock: true,
                close: function () {
                    var selNodeJson = art.dialog.data('selJson'); // 读取人员选择返回值
                    //  alert(selNodeJson);
                    if (selNodeJson != "") {
                        try {
                            var data = JSON.parse(selNodeJson);
                            var rows = $("#topicSelect").datagrid("getRows");
                            for (i = 0; i < rows.length; i++) {
                                if (rows[i].TopicId == id) {
                                    var row = rows[i];
                                    row.EmployeeId = data[0].EmployeeId;
                                    row.EmployeeName = data[0].EmployeeName;
                                    row.EmployeeTitle = data[0].EmployeeTitle;
                                    row.RoleId = data[0].RoleId;
                                    $("#topicSelect").datagrid("updateRow", { index: i, row: row });
                                    break;
                                }
                            }
                        } catch (ex) { }
                    }
                }
            }, true);

        }

        //保存会议议题        
        function SaveMeetingTopic() {
            //
            GetSelectTopic(); //结束编辑
            var data = $('#topicSelect').datagrid('getData');
            if (data.total == 0) {
                $.messager.alert("提示", "议题必选");
                return false;
            }

            var str = JSON.stringify(data.rows);
            var Id = $("#Id").val();
            var postData = { Id: Id, data: str };
            //提交

            $.post("MeetingOperation.ashx?method=SaveMeetingTopic", postData, function (data) {
                if (data.success == true) {
                    InitStep4();

                    return true;
                } else {
                    return false;
                    $("#error").val(data.Message); $.messager.alert("提示", data.Message);
                }
            });
        }

        /*************************step3结束*******************************************/
        /*************************step4开始*******************************************/
        function InitStep4() {
            try {
                $("#meetingTopicSelect").datagrid({
                    url: 'MeetingOperation.ashx?method=GetSelectTopic&Id=' + $("#Id").val(),
                    singleSelect: true,
                    view: detailview,
                    detailFormatter: function (index, row) {
                        return '<div style="padding:2px"><table id="ddvMeetingTopicDoc-' + index + '"></table></div>';
                    },
                    onExpandRow: function (index, row) {
                        $('#ddvMeetingTopicDoc-' + index).datagrid({
                            url: 'MeetingOperation.ashx?method=GetMeetingTopicDocument&Id=' + row.TopicId,
                            nowrap: false,
                            singleSelect: true,
                            rownumbers: true,
                            loadMsg: '',
                            height: 'auto',
                            columns: [[
                            { field: 'Name', title: '文档名称', width: 385 },
                            { field: 'MeetingId', title: '', hidden: true },
                            { field: 'TopicId', title: '', hidden: true },
                            { field: 'DocumentId', title: '', hidden: true },
                            { field: 'action', title: '操作', formatter: formatDocDel }
                        ]],
                            onResize: function () {
                                $('#meetingTopicSelect').datagrid('fixDetailRowHeight', index);
                            },
                            onLoadSuccess: function () {
                                setTimeout(function () {
                                    $('#meetingTopicSelect').datagrid('fixDetailRowHeight', index);
                                }, 0);
                            }
                        });
                        $('#meetingTopicSelect').datagrid('fixDetailRowHeight', index);
                    }
                });
            } catch (ex) { }
        }
        function formatDocDel(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"RemoveMeetingDocument('" + row.MeetingId + "','" + row.TopicId + "','" + row.DocumentId + "');\"  >移除</a> ";
        }
        function RemoveMeetingDocument(mId, tId, dId) {
            $.messager.confirm("询问", "确定要移除该文档吗？", function (c) {
                if (!c) return;
                var postData = { MeetingId: mId, TopicId: tId, DocumentId: dId };
                $.post("MeetingOperation.ashx?method=DeleteMeetingTopicDocument", postData, function (data) {
                    if (data.success == true) {
                        $("#meetingTopicSelect").datagrid("reload");
                        $.messager.alert("提示", "删除成功");
                    } else {
                        $.messager.alert("提示", data.Message);
                    }
                });
            });
        }
        function AddMeetingTopicDoc(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"AddMeetingDocument('" + row.MeetingId + "','" + row.TopicId + "');\"  >新增文档</a> ";
        }
        function AddMeetingDocument(meetingId, topicId) {
            var url = 'MeetingFile.aspx?MeetingId=' + meetingId + '&TopicId=' + topicId;
            art.dialog.open(url, {
                id: 'AAA', width: 430, height: 380, lock: true,
                close: function () {
                    // var flag = art.dialog.data('result'); // 读取返回值True表示正确
                    $("#meetingTopicSelect").datagrid("reload");
                    //                    $("#FlagSaveOk").val(flag);
                    //                    $("#selName").html(art.dialog.data('selName'));
                    //                    $("#selId").html(art.dialog.data('selId'));
                }
            }, false);
        }
        /*************************step4结束*******************************************/
        /*************************地块信息*******************************************/
        function InitPlate() {
            try {
                $("#meetingTopicPlate").datagrid({
                    url: 'MeetingOperation.ashx?method=GetSelectTopic&Id=' + $("#Id").val(),
                    singleSelect: true,
                    view: detailview,
                    detailFormatter: function (index, row) {
                        return '<div style="padding:2px"><table id="ddvmeetingTopicPlate-' + index + '"></table></div>';
                    },
                    onExpandRow: function (index, row) {
                        $('#ddvmeetingTopicPlate-' + index).datagrid({
                            url: 'MeetingOperation.ashx?method=GetMeetingTopicPlate&Id=' + row.TopicId,
                            nowrap: false,
                            singleSelect: true,
                            rownumbers: true,
                            loadMsg: '',
                            height: 'auto',
                            columns: [[
                            { field: 'Name', title: '地块名称', width: 385 },
                            { field: 'MeetingId', title: '', hidden: true },
                            { field: 'TopicId', title: '', hidden: true },
                            { field: 'PlateId', title: '', hidden: true },
                            { field: 'action', title: '操作', formatter: formatPlateDel }
                        ]],
                            onResize: function () {
                                $('#meetingTopicPlate').datagrid('fixDetailRowHeight', index);
                            },
                            onLoadSuccess: function () {
                                setTimeout(function () {
                                    $('#meetingTopicPlate').datagrid('fixDetailRowHeight', index);
                                }, 0);
                            }
                        });
                        $('#meetingTopicPlate').datagrid('fixDetailRowHeight', index);
                    }
                });
            } catch (ex) { }
        }
        function formatPlateDel(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"RemoveMeetingPlate('" + row.MeetingId + "','" + row.TopicId + "','" + row.PlateId + "');\"  >移除</a> ";
        }
        function RemoveMeetingPlate(mId, tId, dId) {
            $.messager.confirm("询问", "确定要移除该文档吗？", function (c) {
                if (!c) return;
                var postData = { MeetingId: mId, TopicId: tId, PlateId: dId };
                $.post("MeetingOperation.ashx?method=DeleteMeetingTopicPlate", postData, function (data) {
                    if (data.success == true) {
                        $("#meetingTopicPlate").datagrid("reload");
                        $.messager.alert("提示", "删除成功");
                    } else {
                        $.messager.alert("提示", data.Message);
                    }
                });
            });
        }
        function AddMeetingTopicPlate(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"AddMeetingPlate('" + row.MeetingId + "','" + row.TopicId + "');\"  >新增地块信息</a> ";
        }
        function AddMeetingPlate(meetingId, topicId) {
            var url = 'MeetingPlateFile.aspx?MeetingId=' + meetingId + '&TopicId=' + topicId;
            art.dialog.open(url, {
                id: 'AAA', width: 430, height: 380, lock: true,
                close: function () {
                    // var flag = art.dialog.data('result'); // 读取返回值True表示正确
                    $("#meetingTopicPlate").datagrid("reload");
                    //                    $("#FlagSaveOk").val(flag);
                    //                    $("#selName").html(art.dialog.data('selName'));
                    //                    $("#selId").html(art.dialog.data('selId'));
                }
            }, false);
        }
        /*************************地块信息结束*******************************************/
        /*************************投票开始*******************************************/
        function InitVote() {

            $("#voteSelect").datagrid({
                url: 'MeetingOperation.ashx?method=GetSelectVote&Id=' + $("#Id").val(),
                singleSelect: true
            });
        }

        function SelectVote() {
            var radStr = Math.random();
            var url = "../SelectBase/SelectVote.aspx" + '?Radstr=' + radStr;
            art.dialog.open(url, {
                id: 'AddVote', title: '选择投票', width: 600, height: 390, lock: true,
                close: function () {
                    var selJson = art.dialog.data('selJson'); // 读取人员选择返回值
                    //  alert(selNodeJson);
                    if (selJson != "") {
                        try {
                            var data = JSON.parse(selJson);
                            DelAllSelectVote();
                            for (i = 0; i < data.length; i++) {
                                $('#voteSelect').datagrid('appendRow', data[i]);
                            }
                        } catch (ex) { }
                    }
                }
            }, true);
        }

        function AddMeetingVote(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"SelectMeetingVote('" + row.Id + "','" + row.Theme + "');\"  >选择</a> ";
        }
        function SelectMeetingVote(voteId, theme) {
            var data = $('#voteSelect').datagrid('getData');

            for (i = 0; i < data.total; i++) {
                if (data.rows[i].VoteId == voteId) {
                    return;
                }
            }
            var str = { VoteId: voteId, Theme: theme };
            $('#voteSelect').datagrid('appendRow', str);
            var editIndex = $('#voteSelect').datagrid('getRows').length - 1;
            $('#voteSelect').datagrid('selectRow', editIndex)
						.datagrid('beginEdit', editIndex);
        }
        function DelSelectVote(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"DelMeetingSelectVote('" + row.VoteId + "');\"  >移除</a> ";
        }
        function DelAllSelectVote() {
            var rows = $('#voteSelect').datagrid('getRows');
            for (i = rows.length - 1; i >= 0; i--) {
                $('#voteSelect').datagrid('deleteRow', i);
            }
        }
        function DelMeetingSelectVote(voteId) {
            var data = $('#voteSelect').datagrid('getData');
            var index = -1;
            for (i = 0; i < data.total; i++) {
                if (data.rows[i].VoteId == voteId) {
                    index = i;
                    break;
                }
            }
            $('#voteSelect').datagrid('deleteRow', index);
        }
        //保存投票信息
        function SaveMeetingVote() {

            var data = $('#voteSelect').datagrid('getData');
            var str = JSON.stringify(data.rows);
            var Id = $("#Id").val();
            var postData = { Id: Id, data: str };
            //提交

            $.post("MeetingOperation.ashx?method=SaveMeetingVote", postData, function (data) {
                if (data.success == true) {
                    return true;
                } else {
                    return false;
                    $("#error").val(data.Message); $.messager.alert("提示", data.Message);
                }
            });
        }
        /*************************投票结束*******************************************/
    </script>
    <style type="text/css">
        .chk
        {
            border: 0;
        }
        input type[radio]
        {
            border: 0;
        }
    </style>
</head>
<body style="background-color: #F8F8F8;">
    <table align="center" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <input type='hidden' name="issubmit" value="1" />
                <!-- Tabs -->
                <div id="wizard" class="swMain">
                    <ul>
                        <li><a href="#step-1">
                            <label class="stepNumber">
                                1</label>
                            <span class="stepDesc">创建会议</span></a></li>
                        <li><a href="#step-2">
                            <label class="stepNumber">
                                2</label>
                            <span class="stepDesc">设置参会人员</span></a></li>
                        <li><a href="#step-3">
                            <label class="stepNumber">
                                3</label>
                            <span class="stepDesc">关联会议议题</span></a></li>
                        <li><a href="#step-4">
                            <label class="stepNumber">
                                4</label>
                            <span class="stepDesc">查看议题资料</span></a></li>
                          <li><a href="#step-5">
                            <label class="stepNumber">
                                5</label>
                            <span class="stepDesc">议题地块信息<small></small> </span></a></li>
                        <li><a href="#step-6">
                            <label class="stepNumber">
                                6</label>
                            <span class="stepDesc">设置会议投票<small></small> </span></a></li>
                        <li><a href="#step-7">
                            <label class="stepNumber">
                                7</label>
                            <span class="stepDesc">激活会议</span></a></li>
                    </ul>
                    <div id="step-1">
                        <form action="#" id="formSetp1" method="post">
                        <input id="meetRoom" type="hidden" />
                        <input id="meetCategory" type="hidden" />
                        <table class="showView1" cellpadding="1" cellspacing="1" align="center">
                            <tr>
                                <td class="title">
                                    <span style="color: Red;">*</span> 会议类型:
                                </td>
                                <td class="td_Modify1">
                                    <select id="CategoryId" class="easyui-combobox" editable="false" style="width: 403px;"
                                        required="true">
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    <span style="color: Red;">*</span> 会议名称:
                                </td>
                                <td class="td_Modify1">
                                    <input type="hidden" id="Id" /><!--会议ID-->
                                    <input id="Name" name="Name" type="text" class="easyui-validatebox" required="true"
                                        style="width: 400px" />
                                </td>
                            </tr>
                            <tr style="display: none;">
                                <td class="title">
                                    <span style="color: Red;">*</span>会议主持人:
                                </td>
                                <td class="td_Modify1">
                                    <input type="hidden" id="HostId" />
                                    <input id="Host" type="text" class="easyui-validatebox" readonly="readonly" style="width: 400px" /><img
                                        src="../../Images/Search.ico" onclick="GetMeetingHost();" alt="选择会议主持人" id="SelectHostId" />
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    <span style="color: Red;">*</span>开始时间:
                                </td>
                                <td class="td_Modify1">
                                    <input id="StartDate" onfocus="WdatePicker({startDate:'%y-%M-01 00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"
                                        style="width: 400px" />
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    <span style="color: Red;">*</span>预计结束时间:
                                </td>
                                <td class="td_Modify1">
                                    <input id="EndDate" onfocus="WdatePicker({startDate:'%y-%M-01 00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"
                                        style="width: 400px" />
                                    <%--<a id="A1" class="easyui-linkbutton" onclick="">计算</a>--%>
                                </td>
                            </tr>
                            <tr style="display: none;">
                                <td class="title">
                                    持续时间:
                                </td>
                                <td class="td_Modify1">
                                    <input id="Duration" name="peoplecount" value="1" class="easyui-numberspinner" precision="1"
                                        style="width: 403px" />
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    <span style="color: Red;">*</span>会议室:
                                </td>
                                <td class="td_Modify1">
                                    <input id="RoomId" class="easyui-combobox" required="true" style="width: 403px; line-height: 25px;">
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    <span style="color: Red;">*</span>视频会议室:
                                </td>
                                <td class="td_Modify1">
                                    <input id="VideoRoomId" class="easyui-combobox" required="true" style="width: 403px;
                                        line-height: 25px;">
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    会议状态:
                                </td>
                                <td class="td_Modify1">
                                    <select id="Status" class="easyui-combobox" name="vcount" style="width: 403px;">
                                        <option value="1">准备</option>
                                        <option value="2">激活</option>
                                        <option value="3">取消</option>
                                        <option value="4">关闭</option>
                                    </select>
                                </td>
                            </tr>
                        </table>
                        </form>
                    </div>
                    <div id="step-2">
                        <form action="#" id="formSetp2" method="post">
                        <table class="showView1" cellpadding="0" cellspacing="0" align="center">
                            <tr>
                                <td class="title">
                                    会议名称:
                                </td>
                                <td class="td_Modify1" style="">
                                    <span id="Step2MeetingName"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    来源选择:
                                </td>
                                <td class="td_Modify1" style="">
                                    <input type="radio" value="stand" class="chk" name="sel" onclick="SetSelectEmpoyee(this);"
                                        checked="checked" id="standMeeting" />常设会议
                                    <input type="radio" value="oa" class="chk" name="sel" onclick="SetSelectEmpoyee(this);"
                                        id="oaUser" />电子政务获取
                                </td>
                            </tr>
                            <tr id="trStandMeeting">
                                <td class="title">
                                    常设会议:
                                </td>
                                <td class="td_Modify1" style="">
                                    <input id="StandMeeting" class="easyui-combobox" style="width: 403px; line-height: 25px;">
                                </td>
                            </tr>
                            <%--  <tr id="trOAuser" style="display: none;">
                                <td class="title">
                                    可选人员：
                                </td>
                                <td class="td_Modify1" style="">
                                    <div style="width: 480px; height: 180px; text-align: left; overflow: auto;">
                                        <ul id="treeMain" class="ztree">
                                         <img id="imgShow" alt="请稍后，正在加载数据……" src="../../Images/loading.gif" />
                                        </ul>
                                    </div>
                                </td>
                            </tr>--%>
                            <tr>
                                <td class="title">
                                    <span style="color: Red;">*</span>参会人员:
                                </td>
                                <td class="td_Modify1">
                                    <a id="editSelect" class="easyui-linkbutton" onclick="AddEmployee();">选择参会人</a>
                                    <a id="editSort" class="easyui-linkbutton" onclick="EditSort();">编辑排序</a>
                                    <table id="tbEmployee" data-options="idField: 'EmployeeId'" loadmsg="正在处理数据请等待..."
                                        class="easyui-datagrid" singleselect="true" style="width: 480px; height: 300px">
                                        <thead>
                                            <tr>
                                                <th data-options="field:'EmployeeId',hidden:true">
                                                    编号
                                                </th>
                                                <th data-options="field:'EmployeeName',width:80">
                                                    姓名
                                                </th>
                                                <th data-options="field:'RoleId',hidden:true">
                                                    编号
                                                </th>
                                                <th data-options="field:'EmployeeTitle',width:70 ">
                                                    职务
                                                </th>
                                                <th data-options="field:'Mobile',width:100">
                                                    手机
                                                </th>
                                                <th data-options="field:'Sort',width:80,editor:'text'">
                                                    排序
                                                </th>
                                            </tr>
                                        </thead>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    会议主持人:
                                </td>
                                <td class="td_Modify1">
                                    <input type="hidden" id="Step2HostTitle" /><input type="hidden" id="Step2HostId" /><input
                                        type="hidden" id="Step2RoleId" />
                                    <input id="Step2Host" type="text" class="easyui-validatebox" readonly="readonly"
                                        style="width: 400px" /><a class="easyui-linkbutton" onclick="SetHost();">设置主持人</a>
                                </td>
                            </tr>
                        </table>
                        </form>
                    </div>
                    <div id="step-3">
                        <table class="showView1" cellpadding="0" cellspacing="0" align="center">
                            <tr>
                                <td class="title">
                                    会议名称:
                                </td>
                                <td class="td_Modify1">
                                    <span id="Step3MeetingName"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="title">
                                    关联议题:
                                </td>
                                <td class="td_Modify1">
                                    <a id="A1" class="easyui-linkbutton" onclick="SelectTopic();">选择议题</a> <a id="A2"
                                        class="easyui-linkbutton" onclick="EditTopicSort();">编辑</a>
                                    <table id="topicSelect" style="width: 550px; height: 300px;" singleselect="true"
                                      nowrap="false"   fitcolumns="true">
                                        <thead>
                                            <tr>
                                                <th data-options="field:'TopicId',width:80,hidden:true">
                                                    编号
                                                </th>
                                                <th data-options="field:'Title',width:240">
                                                    标题
                                                </th>
                                                <th data-options="field:'EmployeeId',width:100,hidden:true">
                                                    人员编号
                                                </th>
                                                <th data-options="field:'EmployeeTitle',width:80,hidden:true">
                                                    职务
                                                </th>
                                                <th data-options="field:'EmployeeName',width:70 ,editor:'text'">
                                                    主讲人
                                                </th>
                                                <th data-options="field:'RoleId',width:80,hidden:true">
                                                </th>
                                                <th data-options="field:'Sort',width:40,editor:'text'">
                                                    排序
                                                </th>
                                                <th data-options="field:'action',width:80,formatter:formatTopicEmployee">
                                                </th>
                                                <%--<th data-options="field:'action',width:80,formatter:DelSelect">
                                                </th>--%>
                                            </tr>
                                        </thead>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="step-4">
                        <table id="meetingTopicSelect" style="width: 700px; height: 460px;" singleselect="true"
                          nowrap="false"   fitcolumns="true">
                            <thead>
                                <tr>
                                    <th data-options="field:'MeetingId',width:80,hidden:true">
                                        编号
                                    </th>
                                    <th data-options="field:'TopicId',width:80,hidden:true">
                                        编号
                                    </th>
                                    <th data-options="field:'Title',width:240">
                                        议题标题
                                    </th>
                                    <th data-options="field:'EmployeeId',width:100,hidden:true">
                                        人员编号
                                    </th>
                                    <th data-options="field:'EmployeeTitle',width:80,hidden:true">
                                        职务
                                    </th>
                                    <th data-options="field:'EmployeeName',width:60 ">
                                        主讲人
                                    </th>
                                    <th data-options="field:'RoleId',width:80,hidden:true">
                                    </th>
                                    <th data-options="field:'Sort',width:40,editor:'text'">
                                        排序
                                    </th>
                                    <th data-options="field:'action',width:80,formatter:AddMeetingTopicDoc">
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div id="step-5">
                         <table id="meetingTopicPlate" style="width: 700px; height: 460px;" singleselect="true"
                          nowrap="false"   fitcolumns="true">
                            <thead>
                                <tr>
                                    <th data-options="field:'MeetingId',width:80,hidden:true">
                                        编号
                                    </th>
                                    <th data-options="field:'TopicId',width:80,hidden:true">
                                        编号
                                    </th>
                                    <th data-options="field:'Title',width:240">
                                        议题标题
                                    </th>
                                    <th data-options="field:'EmployeeId',width:100,hidden:true">
                                        人员编号
                                    </th>
                                    <th data-options="field:'EmployeeTitle',width:80,hidden:true">
                                        职务
                                    </th>
                                    <th data-options="field:'EmployeeName',width:60 ">
                                        主讲人
                                    </th>
                                    <th data-options="field:'RoleId',width:80,hidden:true">
                                    </th>
                                    <th data-options="field:'Sort',width:40,editor:'text'">
                                        排序
                                    </th>
                                    <th data-options="field:'action',width:80,formatter:AddMeetingTopicPlate">
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div id="step-6">
                        <table class="showView1" cellpadding="0" cellspacing="0" align="center">
                            <tr>
                                <td class="title">
                                    已选投票:
                                </td>
                                <td class="td_Modify1" style="">
                                    <a id="A3" class="easyui-linkbutton" onclick="SelectVote();">选择投票</a>
                                    <table id="voteSelect" style="width: 600px; height: 260px;" singleselect="true" fitcolumns="true">
                                        <thead>
                                            <tr>
                                                <th data-options="field:'VoteId',width:80,hidden:true">
                                                    投票编号
                                                </th>
                                                <th data-options="field:'MeetingId',width:80,hidden:true">
                                                    投票编号
                                                </th>
                                                <th data-options="field:'Theme',width:80">
                                                    投票主题
                                                </th>
                                                <th data-options="field:'action',width:80,formatter:DelSelectVote">
                                                </th>
                                            </tr>
                                        </thead>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </div>                   
                     <div id="step-7">
                        会议已经激活
                    </div>
                </div>
                <!-- End SmartWizard Content -->
            </td>
        </tr>
    </table>
</body>
</html>
